package com.winning.util.ncpquery.controller;

import com.alibaba.fastjson.JSON;
import com.winning.util.excelutil.common.controller.BaseController;
import com.winning.util.excelutil.common.dto.BaseProtocolOut;
import com.winning.util.ncpquery.entity.NcpEntity;
import com.winning.util.ncpquery.service.NcpQueryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @作者：caopengfei
 * @时间：2020/2/15
 */
@RestController
@RequestMapping("api")
@Slf4j
public class NcpQueryCOntroller extends BaseController {

  @Autowired
  private NcpQueryService ncpQueryService;

    @Autowired
    private NcpEntity ncpEntity;

  @GetMapping("wjw/gateway/httpproxy")
  public String getPersonInfo(String xm,String sfzhm,String type){
       String result="";
       try{
           if("qzys".equals(type)){
               result =  ncpQueryService.queryIsPersonInfo(xm,sfzhm,ncpEntity.getSid0(),ncpEntity.getAppKey0());
           }else{
               result =  ncpQueryService.queryIsPersonInfo(xm,sfzhm,ncpEntity.getSid1(),ncpEntity.getAppKey1());
           }

       }catch (Exception e){
           log.error("获取信息",e);
           result = JSON.toJSONString(BaseProtocolOut.error("服务正在维护"));
       }
       return result;
  }

}
